﻿namespace Sidvall.WorkItemManager.UI.Entities
{
	public sealed partial class IntervalRetryPolicy
	{
		#region Public Members

		#region Deserialize

		public static IntervalRetryPolicy Deserialize(string value)
		{
			Sidvall.WorkItemManager.Net.Services.V1.IntervalRetryPolicy dataItem;
			IntervalRetryPolicy item;

			dataItem = null;
			try
			{
				if (!string.IsNullOrWhiteSpace(value))
					dataItem = Sidvall.Serialization.SerializerManager.Current.Deserialize<Sidvall.WorkItemManager.Net.Services.V1.IntervalRetryPolicy>(value);
			}
			catch
			{
			}
			if (dataItem == null)
			{
				dataItem = new Net.Services.V1.IntervalRetryPolicy();
			}
			item = GetItem(dataItem);
			item.AcceptChanges();

			return item;
		}

		#endregion
		#region GetItem

		public static IntervalRetryPolicy GetItem(Sidvall.WorkItemManager.Data.IIntervalRetryPolicy dataItem)
		{
			IntervalRetryPolicy item;

			if (dataItem == null)
				return null;
			item = new IntervalRetryPolicy();
			item.Import(dataItem, Sidvall.Data.CopySettings.FullCopyAll(Sidvall.Data.DataRowContextOption.None, null));

			return item;
		}

		#endregion
		#region Serialize

		public static string Serialize(Sidvall.WorkItemManager.Data.IIntervalRetryPolicy item)
		{
			Sidvall.WorkItemManager.Net.Services.V1.IntervalRetryPolicy dataItem;

			dataItem = new Net.Services.V1.IntervalRetryPolicy();
			dataItem.Import(item, Sidvall.Data.CopySettings.FullCopyAll(Sidvall.Data.DataRowContextOption.None, null));

			return Sidvall.Serialization.SerializerManager.Current.SerializeObject(dataItem);
		}

		#endregion

		#endregion
	}
}